home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-23 | 4.2 KB | 165 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UTwistDownGlobals.cp
- // ETO20 MacApp 3.3.1, MPW 3.4.1
- // Copyright ©1994-1996 Conrad Kopala
- // Twist Down Lists version 2.0a0 7/15/96
- //----------------------------------------------------------------------------------------
-
- #ifndef __UTWISTDOWNGLOBALS__
- #include "UTwistDownGlobals.h"
- #endif
-
- //MacApp stuff
-
- //Needed for gObjectHeap
- #ifndef __UMEMORY__
- #include "UMemory.h"
- #endif
-
- //ObjectHeap.h required for 68k
- #ifndef __OBJECTHEAP__
- #include "ObjectHeap.h"
- #endif
-
- //Needed for gSizeHeapIncrement
- #ifndef __UNIVERSALSTARTUP__
- #include "UniversalStartup.h"
- #endif
-
- //Needed for gOHRemainingIncrements
- #ifndef PLATFORMMEMORY_H
- #include "PlatformMemory.h"
- #endif
-
- //ToolBox stuff
- #ifndef __STANDARDFILE__
- #include "StandardFile.h"
- #endif
-
- #ifndef __FILES__
- #include "Files.h"
- #endif
-
- //ANSI stuff
- //None
- //----------------------------------------------------------------------------------------
- // Globals
- //----------------------------------------------------------------------------------------
-
- FileFilterYDProcPtr gFileFilterYDProcPtr = MyCustomFileFilter;
- DlgHookYDProcPtr gDlgHookYDProcPtr = MyCustomDlgHook;
-
- //In a normal application the following three globals would be #if qDebug
- Boolean gFailHere;
- Boolean gSendAppleEvents;
- Boolean gUseSystemDirection;
- EAppleEventRouting gAppleEventRouting;
- //----------------------------------------------------------------------------------------
- // MyCustomFileFilter:
- //----------------------------------------------------------------------------------------
- #pragma segment MAGlobalRes
- pascal Boolean MyCustomFileFilter(CInfoPBPtr PB, void *yourDataPtr)
- {
- #pragma unused yourDataPtr
-
- Boolean result;
-
- result = TRUE;
-
- if (((*PB).hFileInfo.ioFlAttrib & ioDirMask) == ioDirMask)
- result = FALSE;
-
- return result;
- }
- //----------------------------------------------------------------------------------------
- // MyCustomDlgHook:
- //----------------------------------------------------------------------------------------
- #pragma segment MAGlobalRes
- pascal short MyCustomDlgHook(short item, DialogPtr theDialog, void *yourDataPtr)
- {
- #pragma unused yourDataPtr
- short result;
- short myType;
- Handle myHandle;
- CStr255 myName;
- Rect myRect;
-
- result = item;
-
- if (GetWRefCon(WindowPtr(theDialog)) != (long)sfMainDialogRefCon)
- return result;
-
- switch (item)
- {
- case sfHookFirstCall:
- {
- myName = "Select";
- GetDialogItem(theDialog, sfItemOpenButton, &myType, &myHandle, &myRect);
- SetControlTitle(ControlHandle(myHandle), myName);
- result = sfHookGoToDesktop;
- }
- break;
-
- case sfHookGoToDesktop:
- result = sfHookNullEvent;
- break;
-
- case sfHookChangeSelection:
- result = sfHookGoToDesktop;
- break;
-
- case sfHookGoToNextDrive:
- result = sfHookNullEvent;
- break;
-
- case sfHookGoToPrevDrive:
- result = sfHookNullEvent;
- break;
-
- case sfItemOpenButton:
- case sfHookOpenFolder:
- result = sfItemOpenButton;
- break;
-
- } //end switch
-
- return result;
- }
- //----------------------------------------------------------------------------------------
- // InitMaxObjectHeapSize:
- //----------------------------------------------------------------------------------------
- #pragma segment MAGlobalRes
- short InitMaxObjectHeapSize()
- {
- long freeMem = FreeMem();
- Size heapSizeIncrement = gSizeHeapIncrement;
- short theNumber = 0;
-
- if (freeMem > kFreeMemReserve)
- theNumber = (freeMem - kFreeMemReserve)/heapSizeIncrement;
-
- if (theNumber >= 1)
- theNumber = theNumber -1;
- else
- theNumber = 0;
-
- return theNumber; //The number of times we'll let the object heap be expanded.
-
- }
- //----------------------------------------------------------------------------------------
- // HaveObjectHeapSpace:
- //----------------------------------------------------------------------------------------
- #pragma segment MAGlobalRes
- Boolean HaveObjectHeapSpace(long amountRequired)
- {
- Boolean result = FALSE;
- long availableInHeap = gObjectHeap -> BytesFree();
- long totalAvailable = availableInHeap + gOHRemainingIncrements*gSizeHeapIncrement;
-
- if (totalAvailable > amountRequired)
- result = TRUE;
-
- return result;
-
- }
- #pragma segment Inline